package com.acme.bankapp.domain.bank;

import com.acme.bankapp.exceptions.bank.NotEnoughFundsException;

public abstract class AbstractAccount implements Account {
	private int balance;

	AbstractAccount(int initialValue) throws IllegalArgumentException {
		if (initialValue < 0) {
			throw new IllegalArgumentException("Negative initial balance");
		}
		balance = initialValue;
	}

	public int getBalance() {
		return balance;
	}

	public void deposit(int sumOfDeposite) {
		balance += sumOfDeposite;
	}

	public void setBalance(int newBalance) throws IllegalArgumentException {
		if (newBalance < 0) {
			throw new IllegalArgumentException("Negative initial balance");
		}
		balance = newBalance;
	}

	public static long decimalValue(double sum) {
		return Math.round(sum);
	}

	public abstract void withdraw(int sum) throws NotEnoughFundsException;

	public abstract int maximumAmountToWithdraw();
	public abstract int getCredit();

}
